using System;
using System.Collections.Generic;
using DAL;
using Entities;
using Utility;
using System.Text;
namespace BUS
{
   public class tbDiadiemBUS
    {
        public static void Insert(tbDiadiem dd)
        {
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
            ddDAL.Insert(dd);
        }
        public static void Update(tbDiadiem dd)
        {
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
            ddDAL.Update(dd);
        }
        public static void Delete(int iD)
        {
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
            ddDAL.Delete(iD);
        }
        public static tbDiadiemCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
            return ddDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDiadiemCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
            return ddDAL.Get(cri.Criter, 0, 0, tbDiadiemCollumn.madiadiem.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDiadiem GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDiadiemCollumn.madiadiem.ToString(), Condition.EQUAL, iD);
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
           tbDiadiemCollection ddColl = ddDAL.Get(cri.Criter, 0, 0, tbDiadiemCollumn.madiadiem.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ddColl.Count > 0)
                return ddColl[0];
            return null;
        }
        public static tbDiadiemCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
            return ddDAL.Get(cri.Criter, 1, number,
            tbDiadiemCollumn.madiadiem.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDiadiemCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDiadiemDAL ddDAL = new tbDiadiemDAL();
            return ddDAL.Get(cri.Criter, 1, number,
            tbDiadiemCollumn.madiadiem.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
